<?php

class Upload extends CI_Controller {

    function __construct() {
        parent::__construct();
        $this->load->helper(array('form', 'url'));
    }

    function index() {
        $this->load->view('upload/upload_form', array('error' => ' '));
    }

    function do_upload() {
        
        $config['upload_path'] = './uploads';
        $config['allowed_types'] = 'gif|jpg|png|JPG|jpeg';
        $config['max_size'] = '100000';
        $config['max_width'] = '2624';
        $config['max_height'] = '2268';
        $this->load->library('upload', $config);
        if (!$this->upload->do_upload()) {
            $error = array('error' => $this->upload->display_errors());

            $this->load->view('upload/upload_form', $error);
        } else {
            $this->load->library('s3');
            $data = $this->upload->data();
       
            var_dump($this->s3->putObjectFile($data["file_path"].$data["file_name"], "leap_s3", $data["orig_name"]));
            $responce["succes_message"] = "File upload succeded!";
            $this->load->view('upload/upload_success', $responce);
        }
    }

}

?>